package com.cskaoyan.gateway.controller.shopping;

import com.mall.commons.result.ResponseData;
import com.mall.commons.result.ResponseUtil;
import com.mall.shopping.IContentService;

import com.mall.shopping.constants.ShoppingRetCode;
import com.mall.shopping.dto.NavListResponse;
import com.mall.user.annotation.Anoymous;
import org.apache.dubbo.config.annotation.Reference;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/shopping")
public class NavigationController {
    @Reference(timeout = 3000,retries = 0,check = false)
    IContentService iContentService;

    @GetMapping("/navigation")
    @Anoymous
    public ResponseData navigation(){
        //无参不需要new request 和参数效验
        NavListResponse navListResponse = iContentService.queryNavList();
        if(!ShoppingRetCode.SUCCESS.getCode().equals(navListResponse.getCode())){
            return new ResponseUtil().setErrorMsg(navListResponse.getMsg());
        }
        return new ResponseUtil().setData(navListResponse.getPannelContentDtos());
    }

}
